package com.aaa.daydemo111.demo1;

/**
 * @Description:
 * @author:LiWei
 * @date:2022年11月01日9:14
 */
public class TestYield {
    public static void main(String[] args) {

        YieldDemo yieldDemo1 = new YieldDemo();
        YieldDemo yieldDemo2 = new YieldDemo();
        yieldDemo1.start();
        yieldDemo2.start();
    }
}
class YieldDemo extends  Thread{

    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            Thread.yield();
            System.out.println(Thread.currentThread().getName()+"===="+i);
        }
    }
}